const CryptoJS = require("crypto-js");
const Key = "CHARGE--SERVICE__CRYPTO";

/**
 * 加密
 * @param word
 * @param key
 */
exports.encrypt = (word, key) => {
	let ckey = key ? key : Key;
	let result = CryptoJS.AES.encrypt(word, ckey, {});

	return result.toString();
};

/**
 * 解密
 * @param word
 * @param key
 */
exports.decrypt = (word, key) => {
	let ckey = key ? key : Key;
	let result = CryptoJS.AES.decrypt(word, ckey, {});

	return result.toString(CryptoJS.enc.Utf8);
};
